/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pa165.pneu.pneuservisbackend.to;

import java.util.Objects;
import pa165.pneu.pneuservisbackend.entiies.Customer;

/**
 *
 * @author Juraj Palenik
 */
public class CustomerTO {
    private Long id;
    private String name;
    private String address;
    private String telephone;

    public CustomerTO() {
    }

    public CustomerTO(Customer customer) {
        if (customer == null) {
            throw new IllegalArgumentException();
        }
        this.id = customer.getId();
        this.name = customer.getName();
        this.address = customer.getAddress();
        this.telephone = customer.getTelephone();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 61 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final CustomerTO other = (CustomerTO) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }
    
    public Customer toCustomer(){
        Customer result = new Customer();
        result.setId(id);
        result.setName(name);
        result.setAddress(address);
        result.setTelephone(telephone);
        return result;
    }

    @Override
    public String toString() {
        return "CustomerTO{" + "id=" + id + ", name=" + name + ", address=" + address + ", telephone=" + telephone + '}';
    }
}
